package models;

import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;

public class PurchaseModel extends AbstractModel {
	public boolean insert(String cid, String sname, String card_no,
			Date expire_date, Date expectedDate, Date deliveredDate) {
		try {
			ps = con.prepareStatement("INSERT INTO Purchase VALUES (receiptId_counter.nextval, sysdate, ?,?,?,?,?,?)");

			ps.setString(1, cid);
			ps.setString(2, sname);
			ps.setString(3, card_no);
			ps.setDate(4, expire_date);
			ps.setDate(5, expectedDate);
			ps.setDate(6, deliveredDate);

			return wrapUp();
		} catch (SQLException ex) {
			return registerException(ex);
		}
	}

	public boolean delete(int receiptId) {
		try {
			ps = con.prepareStatement("DELETE FROM Purchase WHERE receiptId = ?");
			ps.setInt(1, receiptId);
			return wrapUp();
		} catch (SQLException ex) {
			return registerException(ex);
		}
	}

	public ResultSet show() {
		return super.show("Purchase");
	}
}
